package cn.wolfcode.trip.base.domain;

import cn.wolfcode.trip.base.util.JSONUtil;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import lombok.Getter;
import lombok.Setter;

import java.util.HashMap;
import java.util.Map;

@Getter
@Setter
//购票景点的类
@JsonIgnoreProperties("handler")
public class ScenicSpot extends BaseDomain{
    private String scenicSpotName;//景点名称

    private Region region;//景点所在的地区

    private Ticket ticket;//门票

    private Theme theme;//景点主题

    private String coverUrl;//景点封面

    //进行回显所需要的json
    public String getJson(){
        Map<String,Object> map=new HashMap<>();
        map.put("id",id);
        if (ticket != null) {
            map.put("ticketId",ticket.getId());
            map.put("price",ticket.getPrice());
        }
        if(region!=null){
            map.put("regionId",region.getId());
            map.put("regionName",region.getName());
        }
        map.put("scenicSpotName",scenicSpotName);
        if(theme!=null){
            map.put("themeId",theme.getId());
        }
        map.put("coverUrl",coverUrl);
        return JSONUtil.toJSONString(map);
    }
}